package jsu.blogger.controller;


import jsu.blogger.pojo.Result;
import jsu.blogger.service.inter.TagService;
import jsu.blogger.util.ReturnResultUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("tag")
public class TagController {
    private static final Logger logger = LoggerFactory.getLogger(TagController.class);

    @Autowired
    private TagService tagService;
    @GetMapping("/getTags")
    public Result getTagsByKeyword(@RequestParam String keyword) {
        logger.info("标签关键字"+keyword);
        return ReturnResultUtil.success(tagService.searchTagNames(keyword));
    }
    @GetMapping("/getAllTags")
    public Result getAllTags() {
        logger.info("加载所有标签");
        return ReturnResultUtil.success(tagService.getAllTagNames());
    }
}
